﻿using project.B12.Model.Models;
using software.Common.MVVM;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace project.B12.application.Extensions
{
    public class ParameterSegmentationConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value!=null)
            {
                string temp = (value as Test).Result;
                if (string.IsNullOrEmpty(temp))
                {
                    return string.Empty;
                }
                else
                {
                    string[] parts = temp.ToString().Split('/');
                    if (parts.Count()==3)
                    {
                        string parameterValue = parameter as string;
                        switch (parameterValue)
                        {
                            case "阈值法":
                                return parts[0];
                            case "CV法":
                                return parts[1];
                            case "AI法":
                                return parts[2];
                            default:
                                return "Visible";
                        }
                    }
                    else
                        return string.Empty;
                }
            }
            else
                return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
